package com.unnous.user.service.impl;

import com.unnous.user.dao.UserEntityMapper;
import com.unnous.user.entity.UserEntity;
import com.unnous.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserServiceImpl implements UserService {

    @Resource
    UserEntityMapper userMapper;

    public UserEntity getByUsername(String username) {
        UserEntity user =  userMapper.selectByUsername(username);
        if(user == null){
            throw new UsernameNotFoundException("未查到用户："+username+"信息");
        }
        return user;
    }

    @Override
    public int insert(UserEntity userEntity) {
        return userMapper.insert(userEntity);
    }
}
